<template>
	<view>
		<!-- 选择商品 -->
		<view class="goods-type">
			<scroll-view :scroll-x="true" class="scroll-y">
				<view class="goods-type-head" :class="item.store_category_id == typeindex ? 'checktype' : ''" v-for="(item, index) in goodstype" :key="item.store_category_id" @click="checktype(item.store_category_id)">
					<text>{{ item.cate_name}}</text>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {cateList} from '@/api/store.js'
	export default {
		data() {
			return {
				typeindex: '',
				goodstype: []
			}
		},
		methods: {
			checktype: function(e) {
				this.typeindex = e;
				console.log(e)
				console.log(this.typeindex)
				this.$emit('pid',this.typeindex)
			}
		},
		
		beforeCreate(){
			cateList().then(res=>{
				res.data.unshift({
					'store_category_id':'',
					'cate_name': '全部'
				})
				this.goodstype=res.data
				}).catch()
		}
	}
</script>

<style lang="scss" scoped>
.checktype {
	font-size: 36rpx;
	font-weight: bold;
	color: #fd342a;
}
.goods-type {
		padding: 27rpx 0;
		scroll-view {
			overflow: hidden;
			white-space: nowrap;
		}
		.goods-type-head {
			display: inline-block;
		}
		text {
			display: inline-block;
			height: 50rpx;
			padding: 0 30rpx;
			line-height: 50rpx;
			text-align: center;
		}
	}
</style>
